package com.xwj.exception.unified.enums;

import com.xwj.exception.unified.asserts.BusinessExceptionAssert;
import com.xwj.exception.unified.exception.BusinessException;
import com.xwj.exception.unified.exception.StudentNotFoundException;
import com.xwj.exception.unified.exception.base.BaseException;

import java.text.MessageFormat;

/**
 * 业务异常枚举
 */
public enum BusinessEnum implements BusinessExceptionAssert {

    NOT_EXISTS("U101B001", 400, "{0}不存在"),
    ACCOUNT_FREEZE("U101B002", 400, "账号被冻结"),
    USER_PWD_ERROR("U101B003", 400, "用户密码错误"),
    // 还可以在这里覆写 newException 方法
    STUDENT_NOT_EXISTS("U102B001", 400, "学员不存在哦") {
        @Override
        public BaseException newException() {
            return new StudentNotFoundException(this);
        }
    },
    ;

    /**
     * 返回码
     */
    private String code;
    /**
     * 状态码
     */
    private Integer http;
    /**
     * 返回消息
     */
    private String message;

    BusinessEnum(String code, Integer http, String message) {
        this.code = code;
        this.http = http;
        this.message = message;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public Integer getHttp() {
        return http;
    }

}
